#include "test_base.hpp"

TEST(RandomAccessIteratorAdaptor, emptyVector_rangeIsEmpty)
{
	ivec v = {};
	auto r = all(v);
	ASSERT_TRUE(r.empty());
}

TEST(RandomAccessIteratorAdaptor, oneElementVector_rangeIsNotEmpty)
{
	ivec v = { 1 };
	auto r = all(v);
	ASSERT_FALSE(r.empty());
}

TEST(RandomAccessIteratorAdaptor, oneElementVector_frontReturnsFirstElement)
{
	ivec v = { 1 };
	auto r = all(v);
	ASSERT_EQ(1, r.front());
}

TEST(RandomAccessIteratorAdaptor, oneElementVector_popFrontLeavesEmpty)
{
	ivec v = { 1 };
	auto r = all(v);
	r.pop_front();
	ASSERT_TRUE(r.empty());
}

TEST(RandomAccessIteratorAdaptor, twoElementVector_popFront_frontReturnsSecondElement)
{
	ivec v = { 1, 2 };
	auto r = all(v);
	r.pop_front();
	ASSERT_EQ(2, r.front());
}

TEST(RandomAccessIteratorAdaptor, emptyVector_positionIsNone)
{
  ivec v = {};
  auto r = all(v);
  ASSERT_FALSE(static_cast<bool>(r.front_position()));
  ASSERT_TRUE(!r.front_position());
}

TEST(RandomAccessIteratorAdaptor, oneElementVector_positionIsValid)
{
  ivec v = { 1 };
  auto r = all(v);
  ASSERT_FALSE(!r.front_position());
  ASSERT_TRUE(static_cast<bool>(r.front_position()));
}

TEST(RandomAccessIteratorAdaptor, oneElementVector_positionReferencesFirstElement)
{
  ivec v = { 1 };
  auto r = all(v);
  ASSERT_EQ(1, *r.front_position());
}
